/*
*  Copyright 2019-2020 Zheng Jie
*
*  Licensed under the Apache License, Version 2.0 (the "License");
*  you may not use this file except in compliance with the License.
*  You may obtain a copy of the License at
*
*  http://www.apache.org/licenses/LICENSE-2.0
*
*  Unless required by applicable law or agreed to in writing, software
*  distributed under the License is distributed on an "AS IS" BASIS,
*  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*  See the License for the specific language governing permissions and
*  limitations under the License.
*/
package me.zhengjie.domain;

import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.bean.copier.CopyOptions;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;
import org.springframework.format.annotation.DateTimeFormat;

import javax.persistence.*;
import javax.validation.constraints.NotEmpty;
import java.io.Serializable;
import java.util.Date;

/**
* @website https://el-admin.vip
* @description /
* @author LongYang
* @date 2021-06-28
**/
@Entity
@Data
@Table(name="kw_student")
@EntityListeners(AuditingEntityListener.class)
public class KwStudent implements Serializable {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "id")
    @ApiModelProperty(value = "id")
    private Integer id;

    @Column(name = "student_number")
    @ApiModelProperty(value = "学号")
    private String studentNumber;

    @Column(name = "name_cn")
    @ApiModelProperty(value = "姓名")
    @NotEmpty(message = "姓名不可为空")
    private String nameCn;

    @Column(name = "id_card")
    @ApiModelProperty(value = "身份证号")
    @NotEmpty(message = "身份证号不可为空")
    private String idCard;

    @Column(name = "phone")
    @ApiModelProperty(value = "手机号")
    @NotEmpty(message = "手机号不可为空")
    private String phone;

    @Column(name = "college")
    @ApiModelProperty(value = "学院")
    private String college;

    @Column(name = "del_flag")
    @ApiModelProperty(value = "删除标志（0.未删除，1.已删除）")
    private String delFlag;

    @Column(name = "classes")
    @ApiModelProperty(value = "班级")
    private String classes;

    @Column(name = "create_time",columnDefinition = "datetime COMMENT '创建时间'")
    @ApiModelProperty(value = "创建时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @CreatedDate
    private Date createTime;

    @Column(name = "update_time",columnDefinition = "datetime COMMENT '修改时间'")
    @ApiModelProperty(value = "修改时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @CreatedDate
    @LastModifiedDate
    private Date updateTime;

    public void copy(KwStudent source){
        BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
    }
}